# in engine plugin
def get_history_of_one_subprocess(expression,workflow_instance_ids = [])
	current_fei = expression.fei
	workflow_instance_ids << current_fei.workflow_instance_id
	
	if current_fei.workflow_definition_name == "some_definition_name"
		 return [current_fei.workflow_definition_name,workflow_instance_ids.uniq]
	else
		get_history_of_one_subprocess(expression.get_parent,workflow_instance_ids)
	end
end


def get_all_history(root_wfid)
	status = engine.process_status(root_wfid)
	current_expressions = status.expressions
	history_hash = {}
	current_expressions.each do |expression|
		tmp = get_history_of_one_subprocess(expression)
		histroy_hash[tmp.first] = tmp.last		
	end	
	history_hash
end

# engine controller
def whole_history
	history_hash = get_all_history(params[:wfid])
	respond_to do |format|
		format.xml { render :xml => history_hash.to_xml }
	end
end

# wf_proxy controller
def whole_histroy
	workitem = Workitem.find(params[:id])
	wfid = workitem.wfid.split("-").first
	
	old_site = Workitem.site
	Workitem.site = workitem.hosts
	
	history_hash = Workitem.get(:whole_history,:wfid => wfid)
	
	respond_to do |format|
		format.xml { render :xml => history_hash.to_xml }
	end
end

# biz controller
def whole_history
	history_hash = Workitem.get(:whole_history,:id => params[:id]) if params[:id]
	@wi_history_stores = {}
	history_hash.each do |definition_name,wfids|
		@wi_history_stores[definition_name] = WiStore.find(:all,:conditions => ["wfid in (?)",wfids],:order => "id asc")
	end

	respond_to do |format|
		format.html
	end
end
